package com.apac.delegates;

import java.util.Date;
import java.util.List;

import com.apac.bom.Account;
import com.apac.bom.Employee;
import com.apac.bom.EmployeeAccountRequirement;
import com.apac.bom.EmployeeProject;
import com.apac.bom.EmployeeProjectAllowance;
import com.apac.bom.EmploymentSalaryHistory;
import com.apac.bom.HealthCardDependent;
import com.apac.bom.PoSow;
import com.apac.bom.Reference;
import com.apac.bom.SevenSevenDeployedAssetMonitoring;
import com.apac.bom.User;

public class EmployeeDelegate extends AbstractDelegate {

	private Employee empObject;

	public EmployeeDelegate(Employee employee) {
		super();
		this.empObject = employee;
	}

	public EmployeeDelegate() {
		super();
		this.empObject = new Employee();
	}

	public Employee getEmpObject() {
		return empObject;
	}

	public void setEmpObject(Employee employee) {
		this.empObject = employee;
	}

	public String getEmpIdNo() {
		return empObject.getEmpIdNo();
	}

	public void setEmpIdNo(String empIdNo) {
		empObject.setEmpIdNo(empIdNo);
	}

	public Date getEmpBday() {
		return empObject.getEmpBday();
	}

	public void setEmpBday(Date empBday) {
		empObject.setEmpBday(empBday);
	}

	public String getEmpCelNo() {
		return empObject.getEmpCelNo();
	}

	public void setEmpCelNo(String empCelNo) {
		empObject.setEmpCelNo(empCelNo);
	}

	public String getEmpCntctAddr() {
		return empObject.getEmpCntctAddr();
	}

	public void setEmpCntctAddr(String empCntctAddr) {
		empObject.setEmpCntctAddr(empCntctAddr);
	}

	public String getEmpCntctNo() {
		return empObject.getEmpCntctNo();
	}

	public void setEmpCntctNo(String empCntctNo) {
		empObject.setEmpCntctNo(empCntctNo);
	}

	public String getEmpCntctPrsn() {
		return empObject.getEmpCntctPrsn();
	}

	public void setEmpCntctPrsn(String empCntctPrsn) {
		empObject.setEmpCntctPrsn(empCntctPrsn);
	}

	public String getEmpCntctRel() {
		return empObject.getEmpCntctRel();
	}

	public void setEmpCntctRel(String empCntctRel) {
		empObject.setEmpCntctRel(empCntctRel);
	}

	public String getEmpColl() {
		return empObject.getEmpColl();
	}

	public void setEmpColl(String empColl) {
		empObject.setEmpColl(empColl);
	}

	public String getEmpCtshp() {
		return empObject.getEmpCtshp();
	}

	public void setEmpCtshp(String empCtshp) {
		empObject.setEmpCtshp(empCtshp);
	}

	public Date getEmpDateHired() {
		return empObject.getEmpDateHired();
	}

	public void setEmpDateHired(Date empDateHired) {
		empObject.setEmpDateHired(empDateHired);
	}

	public String getEmpEadd() {
		return empObject.getEmpEadd();
	}

	public void setEmpEadd(String empEadd) {
		empObject.setEmpEadd(empEadd);
	}

	public byte getEmpExpYrs() {
		return empObject.getEmpExpYrs();
	}

	public void setEmpExpYrs(byte empExpYrs) {
		empObject.setEmpExpYrs(empExpYrs);
	}

	public String getEmpFirstName() {
		return empObject.getEmpFirstName();
	}

	public void setEmpFirstName(String empFirstName) {
		empObject.setEmpFirstName(empFirstName);
	}

	public String getEmpGrad() {
		return empObject.getEmpGrad();
	}

	public void setEmpGrad(String empGrad) {
		empObject.setEmpGrad(empGrad);
	}

	public String getEmpHdmfNo() {
		return empObject.getEmpHdmfNo();
	}

	public void setEmpHdmfNo(String empHdmfNo) {
		empObject.setEmpHdmfNo(empHdmfNo);
	}

	public String getEmpHlthCardNo() {
		return empObject.getEmpHlthCardNo();
	}

	public void setEmpHlthCardNo(String empHlthCardNo) {
		empObject.setEmpHlthCardNo(empHlthCardNo);
	}

	public String getEmpHlthCardPrem() {
		return empObject.getEmpHlthCardPrem();
	}

	public void setEmpHlthCardPrem(String empHlthCardPrem) {
		empObject.setEmpHlthCardPrem(empHlthCardPrem);
	}

	public String getEmpLandNo() {
		return empObject.getEmpLandNo();
	}

	public void setEmpLandNo(String empLandNo) {
		empObject.setEmpLandNo(empLandNo);
	}

	public String getEmpLastName() {
		return empObject.getEmpLastName();
	}

	public void setEmpLastName(String empLastName) {
		empObject.setEmpLastName(empLastName);
	}

	public String getEmpLicsn() {
		return empObject.getEmpLicsn();
	}

	public void setEmpLicsn(String empLicsn) {
		empObject.setEmpLicsn(empLicsn);
	}

	public String getEmpMidName() {
		return empObject.getEmpMidName();
	}

	public void setEmpMidName(String empMidName) {
		empObject.setEmpMidName(empMidName);
	}

	public String getEmpPhlHlthNo() {
		return empObject.getEmpPhlHlthNo();
	}

	public void setEmpPhlHlthNo(String empPhlHlthNo) {
		empObject.setEmpPhlHlthNo(empPhlHlthNo);
	}

	public byte[] getEmpPhoto() {
		return empObject.getEmpPhoto();
	}

	public void setEmpPhoto(byte[] empPhoto) {
		empObject.setEmpPhoto(empPhoto);
	}

	public String getEmpPresAddr() {
		return empObject.getEmpPresAddr();
	}

	public void setEmpPresAddr(String empPresAddr) {
		empObject.setEmpPresAddr(empPresAddr);
	}

	public String getEmpProvAddr() {
		return empObject.getEmpProvAddr();
	}

	public void setEmpProvAddr(String empProvAddr) {
		empObject.setEmpProvAddr(empProvAddr);
	}

	public String getEmpRmks() {
		return empObject.getEmpRmks();
	}

	public void setEmpRmks(String empRmks) {
		empObject.setEmpRmks(empRmks);
	}

	public String getEmpSkills() {
		return empObject.getEmpSkills();
	}

	public void setEmpSkills(String empSkills) {
		empObject.setEmpSkills(empSkills);
	}

	public String getEmpSssNo() {
		return empObject.getEmpSssNo();
	}

	public void setEmpSssNo(String empSssNo) {
		empObject.setEmpSssNo(empSssNo);
	}

	public String getEmpTin() {
		return empObject.getEmpTin();
	}

	public void setEmpTin(String empTin) {
		empObject.setEmpTin(empTin);
	}

	public List<EmployeeAccountRequirement> getEmployeeAccountRequirements() {
		return empObject.getEmployeeAccountRequirements();
	}

	public void setEmployeeAccountRequirements(
			List<EmployeeAccountRequirement> employeeAccountRequirements) {
		empObject.setEmployeeAccountRequirements(employeeAccountRequirements);
	}

	public String getEmpCvStat() {
		return empObject.getEmpCvStat().getRfrncVal();
	}

	public void setEmpCvStat(Reference empCvStat) {
		empObject.setEmpCvStat(empCvStat);
	}

	public String getEmpGndr() {
		Reference empGndr = empObject.getEmpGndr();
		if (empGndr != null) {
			return empGndr.getRfrncVal();
		}
		return "N/A";
	}

	public void setEmpGndr(Reference empGndr) {
		empObject.setEmpGndr(empGndr);
	}

	public String getEmpStatus() {
		Reference empStatus = empObject.getEmpStatus();
		if (empStatus != null) {
			return empStatus.getRfrncVal();
		}
		return "N/A";
	}

	public void setEmpStatus(Reference empStatus) {
		empObject.setEmpStatus(empStatus);
	}

	public User getUser() {
		return empObject.getUser();
	}

	public void setUser(User user) {
		empObject.setUser(user);
	}

	public List<EmployeeProject> getEmployeeProjects() {
		return empObject.getEmployeeProjects();
	}

	public void setEmployeeProjects(List<EmployeeProject> employeeProjects) {
		empObject.setEmployeeProjects(employeeProjects);
	}

	public List<EmploymentSalaryHistory> getEmploymentSalaryHistory() {
		return empObject.getEmploymentSalaryHistory();
	}

	public void setEmploymentSalaryHistory(
			List<EmploymentSalaryHistory> employmentSalaryHistory) {
		empObject.setEmploymentSalaryHistory(employmentSalaryHistory);
	}

	public List<HealthCardDependent> getHealthCardDependents() {
		return empObject.getHealthCardDependents();
	}

	public void setHealthCardDependents(
			List<HealthCardDependent> healthCardDependents) {
		empObject.setHealthCardDependents(healthCardDependents);
	}

	public String toString() {
		return empObject.toString();
	}

	public EmployeeProject getEmpLatestProject() {
		List<EmployeeProject> empProjs = empObject.getEmployeeProjects();
		if (empProjs != null && empProjs.size() > 0) {
			return empProjs.get(empProjs.size() - 1);
		}
		return null;
	}

	public String getEmpType() {
		EmployeeProject empLatestProj = this.getEmpLatestProject();
		if (empLatestProj != null) {
			Reference projType = empLatestProj.getEmpProjType();
			if (projType != null)
				return projType.getRfrncVal();
		}
		return "N/A";
	}

	public String getEmpJobTitle() {
		EmployeeProject empLatestProj = this.getEmpLatestProject();
		if (empLatestProj != null) {
			return empLatestProj.getEmpProjPosi();
		}
		return "N/A";
	}

	public String getEmpJobLevel() {
		EmployeeProject empLatestProj = this.getEmpLatestProject();
		if (empLatestProj != null) {
			return empLatestProj.getEmpProjJobLevel();
		}
		return "N/A";
	}

	public String getEmpTaxStatus() {
		EmployeeProject empLatestProj = this.getEmpLatestProject();
		if (empLatestProj != null) {
			Reference taxStatus = empLatestProj.getEmpProjTax();
			if (taxStatus != null)
				return taxStatus.getRfrncVal();
		}
		return "N/A";
	}

	public String getEmpLatestProjectName() {
		EmployeeProject empLatestProj = this.getEmpLatestProject();
		if (empLatestProj != null) {
			PoSow empLatestPo = empLatestProj.getPoSow();
			if (empLatestPo != null) {
				return empLatestPo.getProjName();
			}
		}
		return "N/A";
	}

	public String getEmpAccount() {
		EmployeeProject empLatestProj = this.getEmpLatestProject();
		if (empLatestProj != null) {
			PoSow empLatestPo = empLatestProj.getPoSow();
			if (empLatestPo != null) {
				Account empLatestAccount = empLatestPo.getAccount();
				if (empLatestAccount != null) {
					return empLatestAccount.getAcctName();
				}
			}
		}
		return "N/A";
	}

	public EmploymentSalaryHistory getCurrentSalary() {
		List<EmploymentSalaryHistory> salaryhistory = empObject
				.getEmploymentSalaryHistory();
		if (salaryhistory != null && salaryhistory.size() > 0) {
			return salaryhistory.get(salaryhistory.size() - 1);
		}
		return null;
	}

	public EmploymentSalaryHistory getPreviousSalary() {
		List<EmploymentSalaryHistory> salaryhistory = empObject
				.getEmploymentSalaryHistory();
		if (salaryhistory != null && salaryhistory.size() > 1) {
			return salaryhistory.get(salaryhistory.size() - 2);
		}
		return null;
	}

	public String getEmpPrevSalary() {
		EmploymentSalaryHistory previoussalary = this.getPreviousSalary();

		if (previoussalary != null) {
			return "$" + previoussalary.getEmpSal();
		}
		return "N/A";
	}

	public String getEmpCurrSalary() {
		EmploymentSalaryHistory currentsalary = this.getCurrentSalary();

		if (currentsalary != null) {
			return "$" + currentsalary.getEmpSal();
		}
		return "N/A";
	}

	public String getEmpProjAllowance() {
		EmployeeProject latestproject = this.getEmpLatestProject();

		if (latestproject != null) {
			if (latestproject.getEmployeeProjectAllowances() != null) {
				StringBuffer allowances = new StringBuffer();
				for (EmployeeProjectAllowance allowance : latestproject
						.getEmployeeProjectAllowances()) {
					allowances.append(allowance.getEmpAllwType() + " ("
							+ allowance.getEmpAllwAmt() + ") ");
				}

				return allowances.toString();
			}
		}

		return "N/A";
	}

	public String getEmpTools() {
		EmployeeProject latestproject = this.getEmpLatestProject();

		if (latestproject != null) {
			if (latestproject.getSevenSevenDeployedAssetMonitoring() != null) {
				StringBuffer assets = new StringBuffer();
				for (SevenSevenDeployedAssetMonitoring asset : latestproject
						.getSevenSevenDeployedAssetMonitoring()) {
					assets.append(asset.getSevenSevenAssetStatus()
							.getAssetDesc());
				}
			}
		}

		return "N/A";
	}

	public String getEmpDepLoc() {
		EmployeeProject latestproject = this.getEmpLatestProject();

		if (latestproject != null) {
			if (latestproject.getEmpProjLoc() != null) {
				return latestproject.getEmpProjLoc().getRfrncVal();
			}
		}

		return "N/A";
	}

	public String getEmpHmoDependent() {
		if (empObject.getHealthCardDependents() != null) {
			StringBuffer dependents = new StringBuffer();
			for (HealthCardDependent dependent : empObject
					.getHealthCardDependents()) {
				dependents.append(dependent.getDepLstName() + ", "
						+ dependent.getDepFstName() + " | ");
			}

			return dependents.toString();
		}

		return "N/A";
	}

	public String getEmpHmoDependentPremium() {
		if (empObject.getHealthCardDependents() != null) {
			StringBuffer dependents = new StringBuffer();
			for (HealthCardDependent dependent : empObject
					.getHealthCardDependents()) {
				dependents.append(dependent.getDepHlthCardPrem() + " | ");
			}

			return dependents.toString();
		}

		return "N/A";
	}

	public boolean getEmpPersonalEval() {
		EmploymentSalaryHistory salary = this.getCurrentSalary();

		if (salary != null) {
			return salary.getEmpPerfEval();
		}
		return false;
	}

	public boolean getEmpClientEval() {
		EmployeeProject latestproject = this.getEmpLatestProject();

		if (latestproject != null) {
			return latestproject.getEmpProjClntEval();
		}

		return false;
	}

	public boolean getBirRegistrationStatus() {
		if (empObject.getEmployeeAccountRequirements() != null) {
			for (EmployeeAccountRequirement requirement : empObject
					.getEmployeeAccountRequirements()) {
				if (requirement.getAccountRequirements().getRequirement() != null
						&& requirement.getAccountRequirements()
								.getRequirement().getRqmtDesc() != null
						&& requirement.getAccountRequirements()
								.getRequirement().getRqmtDesc()
								.equals("BIR Registration")) {
					return requirement.getStatus();
				}
			}
		}
		return false;
	}
}
